package com.zhilianbao.leyaogo.view.dialog;

import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.bql.variousdialog.widget.base.BaseDialog;
import com.zhilianbao.leyaogo.R;
import com.zhilianbao.marqueeview.MarqueeView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by gyt on 2016/11/26
 */
public class RunProgressDialog extends BaseDialog<RunProgressDialog> {
    @BindView(R.id.iv_loading)
    ImageView   mIvLoading;
    @BindView(R.id.loading_textView)
    MarqueeView mLoadingTextView;
    private AnimationDrawable mAnimationDrawable;

    public RunProgressDialog(Context context) {
        super(context);
    }

    @Override
    public View onCreateView() {
        widthScale(0.55f);
        View view = View.inflate(mContext, R.layout.dialog_run_progress, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setCanceledOnTouchOutside(false);
        setCancelable(false);
    }

    @Override
    public void setUiBeforeShow() {
        getWindow().setDimAmount(0f);
        mIvLoading.setBackgroundResource(R.drawable.loading);
        mAnimationDrawable = (AnimationDrawable) mIvLoading.getBackground();
        mAnimationDrawable.mutate();
        mAnimationDrawable.start();
//
//        List<String> loadingList = new ArrayList<>();
//        loadingList.add(mContext.getString(com.bql.statetypelayout.R.string.loading_1));
//        loadingList.add(mContext.getString(com.bql.statetypelayout.R.string.loading_2));
//        loadingList.add(mContext.getString(com.bql.statetypelayout.R.string.loading_3));
//        loadingList.add(mContext.getString(com.bql.statetypelayout.R.string.loading_4));
//        mLoadingTextView.setNotices(loadingList);
    }


    @Override
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (mAnimationDrawable != null)
            mAnimationDrawable.stop();
    }


    //重写系统返回键处理
    @Override
    public void onBackPressed() {

    }

}
